<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%@ page import="com.conversationboard.model.*" %>
<%@ page import="com.conversationboard.config.*" %>
<%@ page import="com.conversationboard.controller.confirm.Confirm" %>
<%@ page import="java.security.Principal"%>

<%@ page pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8"%>

<%@page import="com.conversationboard.view.MainMenu"%>

<% 
    Principal principal = request.getUserPrincipal();
	Board board = Boards.getBoard(Integer.parseInt(request.getParameter("boardid")));
	request.setAttribute("board", board);
	
	User user = User.get(principal);
	request.setAttribute("user", user);
%>

<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
		<title>Edit Board Attributes</title>
		<link rel="stylesheet" type="text/css" href="<%=Configuration.getInstance().getRoot()%>/Stylesheets/<%=StyleSheets.getStyleSheetFileName(request.getCookies())%>"/>
	</head>

	<body>
	
		<%= MainMenu.display(principal) %>
	
		<div class="headingblock">
			<h1>Edit Board</h1>
		</div>

		<div class="mainblock">
		
			<form class="formsection" action="<%=Configuration.getInstance().getRoot()%>/Admin/AdminUpdateBoardControllerServlet" method="post">
			 	
			 	<%= Confirm.getKey(request.getUserPrincipal().getName()) %>
			 	
				<div class="formsectionlight">
				 	<label for="name"><strong>Board Name:</strong></label>
				 	<input name="name" class="smalltextbox" type="text" size=100 value="${board.name}"/><br /><br />
				 	<label for="description"><strong>Board Description:</strong></label>
				 	<input name="description" class="smalltextbox" type="text" size=100 value="${board.description}"/><br /><br />
				</div>

				<br />

				<div class="formsectionlight">
				 	<label for="sandboxDays"><strong>Days to spend in sandbox:</strong></label>
				 	<input name="sandboxDays" class="tinytextbox" type="text" size=100 value="${board.sandboxDays}"/><br /><br />
				 	
				 	<p>This is the number of days a user must wait after registering, before they can post. Setting it to 0 will
				 	   let a user post immediately after registration.</p>
				 	   
				 	<c:if test="${user.siteAdmin}">
					 	<label for="numberOfNewPosts"><strong>Number of Items on the New Answers Page:</strong></label>
					 	<input name="numberOfNewPosts" class="tinytextbox" type="text" size=100 value="${board.numberOfNewPosts}"/><br /><br />
					 	
					 	<p>Setting this too high will use lots of memory. Very popular boards will want a higher setting, but less popular
					 	   boards will need less. Set accordingly.</p>
				 	</c:if>
				 	   
				</div>

				<br />

				<div class="formsectionlight">
					
					<p><strong>Board Access</strong></p>
				
					<input type="hidden" name="boardId" value="${board.boardId}" />
				
					<input type="radio" name="boardAccess" value="Public" <c:if test="${board.publicBoard}">CHECKED</c:if> />Public: anyone can see, any registered user can post.<br />
					<input type="radio" name="boardAccess" value="Private" <c:if test="${board.privateBoard}">CHECKED</c:if> />Private: only registered, invited users can see or post.<br />
					<input type="radio" name="boardAccess" value="InviteOnly" <c:if test="${board.inviteOnly}">CHECKED</c:if> />Invite Only: anyone can see, but only registered, invited users can post.<br /><br />

					<label for='checkbox6'><strong>Only administrators can invite users</strong></label>
					<input type='checkbox' name='checkbox6' value='adminsAddUsers' <c:if test="${board.adminsAddUsers}">CHECKED</c:if> />

					<p>Applies only to private, or invite only boards. If ticked, only administrators can invite users. If unticked, anyone
					   can invite users.</p>

					<label for='migrateUsers'><strong>Migrate Users</strong></label>
					<input type='checkbox' name='migrateUsers' value='true' <c:if test="${board.adminsAddUsers}">CHECKED</c:if> />

					<p>If you are moving from a public board, to private or invite only, then ticking this option will automatically add
					   anyone who has ever posted on this board to the board membership. You can remove users if you wish once this is done.
					   Unticking it will only authorise you for the board.</p>					

					<label for='noindex'><strong>Disallow Indexing</strong></label>
					<input type='checkbox' name='noindex' value='true' <c:if test="${board.noIndex}">CHECKED</c:if> />

					<p>Checking this box will prevent search engines such as Google, not to index the board's content.</p>

				</div>
				
				<br />

				<div class="formsectionlight">
					
					<label for="hiddenCheckBox"><strong>Hidden board</strong></label>
					<input type="checkbox" name="hiddenCheckBox" value="true" <c:if test="${board.hidden}">CHECKED</c:if> />

					<p>Hidden boards are not shown on the board list. They are however, accessible to the outside world (i.e. they are not private).
					   This can be useful in allowing one server to host boards for many different sites, but not have them viewable on the current
					   board list.</p>

					<label for='popularCheckBox'><strong>Popular Board</strong></label>
					<input type='checkbox' name='popularCheckBox' value='popular' <c:if test="${board.popularBoard}">CHECKED</c:if>  />

					<p>Boards marked popular will be shown in bold and will also default to having a link on the main menu.</p>
	
					<label for='checkbox4'><strong>Requires Registration</strong></label>
					<input type='checkbox' name='checkbox4' value='requireRegistration' <c:if test="${board.requireRegistration}">CHECKED</c:if> />
					
					<p>Disable with extreme caution, as it lets anyone post anonymously.</p>
	
					<label for='checkbox7'><strong>Allow Polls</strong></label>
					<input type='checkbox' name='checkbox7' value='allowPolls' <c:if test="${board.allowPolls}">CHECKED</c:if> />

					<p>If you wish to enable the use of polls on this board, check this box.</p>

					<label for='checkbox8'><strong>Log Admin Actions</strong></label>
					<input type='checkbox' name='checkbox8' value='logAdminActions' <c:if test="${board.logAdminActions}">CHECKED</c:if> />

					<p>Will record admin log entries against this board. They will be shown on the admin log if it is enabled.</p>

				</div>

				

				<br /><br />
			 	<input type="submit" value="      Update Board      " />
			 	
			</form>
		</div>
		
		<!--<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>-->
		<!--<script type="text/javascript">_uacct = "UA-1148679-1";urchinTracker();</script>--> 
		
	</body>
	
</html>
